package logic

import (
	"context"
	"go-zero-demo/distributed-id-rpc/distributed"
	"go-zero-demo/distributed-id-rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetSnowIdLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetSnowIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSnowIdLogic {
	return &GetSnowIdLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetSnowIdLogic) GetSnowId(in *distributed.EmptyReq) (*distributed.SnowIdResp, error) {
	useCase := l.svcCtx.SegmentUseCase
	flakeGetId := useCase.SnowFlakeGetId()
	return &distributed.SnowIdResp{
		Id: flakeGetId}, nil
}
